package main

import (
	"flag"
	"fmt"
	"strings"
)

func main() {
	flagStrTest()


	name := "吉宁abcd1234.tga"
	//mainName := "吉宁abcd"
	//mainExt := ".tga"

	tempStr := name[1:3]
	fmt.Println("name[0:2]字符串：", tempStr)

	/*
		nameL := len(name)
		mainNameL := len(mainName)

		tempStr := name[mainNameL:]
		tempStrL := len(tempStr)

		fileTypeSuffixL := len(mainExt)

		if nameL > mainNameL && nameL > fileTypeSuffixL {
			resultStr := tempStr[:tempStrL-fileTypeSuffixL]

			fmt.Println("截取尾部为:", resultStr)
			resultMatch := regexp.MustCompile(`^\d{4}$`)
			if resultMatch.MatchString(resultStr) {
				fmt.Println("匹配成功")
			} else {
				fmt.Println("匹配失败")
			}
		}
	*/
}

func trimPrefixSuffixTest() {
	name := "吉宁abcd1234.tga"
	mainName := "吉宁abcd"
	mainExt := ".tga"

	trimPrefixStr := strings.TrimPrefix(name, mainName)
	fmt.Println("去取头部后:", trimPrefixStr)

	trimSuffixStr := strings.TrimSuffix(name, mainExt)
	fmt.Println("去取尾部后:", trimSuffixStr)

	trimDeepSuffixStr := strings.TrimSuffix(trimPrefixStr, mainExt)
	fmt.Println("去取头部和尾部后:", trimDeepSuffixStr)
}

func flagStrTest() {
	svc := flag.String("service", "", "https://gw.xrender.com")
	str := *svc
	fmt.Println("svc数据为:",str)
}
